package com.kezesong.leasing.controller;


import com.kezesong.leasing.common.ResponseResult;
import com.kezesong.leasing.common.enums.ShopSearchEnum;
import com.kezesong.leasing.controller.request.QryShopInfoByFlagReqBody;
import com.kezesong.leasing.controller.request.QryShopInfoByIdReqBody;
import com.kezesong.leasing.controller.request.QryShopInfoByNameRequestBody;
import com.kezesong.leasing.entity.ShopInfoEntity;
import com.kezesong.leasing.service.ShopInfoService;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

@RestController
@RequestMapping("/page")
public class ShopController extends BaseController {

    @Autowired
    private ShopInfoService shopInfoService;

    @PostMapping("/getShopList.do")
    @ApiOperation(value = "getShopList", notes = "获取商铺所有列表")
    public ResponseResult<List<ShopInfoEntity>> getShopList(){
        List<ShopInfoEntity> shopInfoList = shopInfoService.getShopInfoList();
        ResponseResult<List<ShopInfoEntity>> listResponseResult = buildSucessResponse(shopInfoList);
        return listResponseResult;
    }

    @PostMapping("/getShopListByName.do")
    @ApiOperation(value = "getShopListByName", notes = "根据名字获取商铺所有列表")
    public ResponseResult<List<ShopInfoEntity>> getShopListByName(@RequestBody QryShopInfoByNameRequestBody requestBody){
        String shopName = requestBody.getShopName();
        List<ShopInfoEntity> shopInfoList = shopInfoService.getShopInfoListByName(shopName);
        ResponseResult<List<ShopInfoEntity>> listResponseResult = buildSucessResponse(shopInfoList);
        return listResponseResult;
    }

    @PostMapping("/getLowPriceShopList.do.do")
    @ApiOperation(value = "getLowPriceShopList.do", notes = "低首付商铺列表")
    public ResponseResult<List<ShopInfoEntity>> getLowPriceShopList(@RequestBody QryShopInfoByFlagReqBody requestBody){
        List<ShopInfoEntity> shopInfoList = shopInfoService.getShopInfoListByShopFlag(ShopSearchEnum.LOWE_PRICE.getCode());
        ResponseResult<List<ShopInfoEntity>> listResponseResult = buildSucessResponse(shopInfoList);
        return listResponseResult;
    }

    @PostMapping("/getMustIntroduceShopList.do")
    @ApiOperation(value = "getMustIntroduceShopList.do", notes = "必推商铺")
    public ResponseResult<List<ShopInfoEntity>> getMustIntroduceShopList(@RequestBody QryShopInfoByFlagReqBody requestBody){
        List<ShopInfoEntity> shopInfoList = shopInfoService.getShopInfoListByShopFlag(ShopSearchEnum.MUST_INTRODUCE.getCode());
        ResponseResult<List<ShopInfoEntity>> listResponseResult = buildSucessResponse(shopInfoList);
        return listResponseResult;
    }

    @PostMapping("/getThisWeekShopList.do")
    @ApiOperation(value = "getThisWeekShopList.do", notes = "本周上新")
    public ResponseResult<List<ShopInfoEntity>> getThisWeekShopList(@RequestBody QryShopInfoByFlagReqBody requestBody){
        List<ShopInfoEntity> shopInfoList = shopInfoService.getShopInfoListByShopFlag(ShopSearchEnum.CURRENT_WEEK.getCode());
        ResponseResult<List<ShopInfoEntity>> listResponseResult = buildSucessResponse(shopInfoList);
        return listResponseResult;
    }

    @PostMapping("/getShopDetails.do")
    @ApiOperation(value = "getShopDetails.do", notes = "商铺详情")
    public ResponseResult<ShopInfoEntity> getShopDetails(@RequestBody QryShopInfoByIdReqBody requestBody){
        ShopInfoEntity shopInfoList = shopInfoService.getShopInfoById(requestBody.getShopId());
        ResponseResult<ShopInfoEntity> listResponseResult = buildSucessResponse(shopInfoList);
        return listResponseResult;
    }
}
